﻿using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace OpenWaves.Video
{
    public class RestDeserializer
    {
        public static T Deserialize<T>(string xml)
        {
            var xs = new XmlSerializer(typeof (T));

            Byte[] byteArray = new UTF8Encoding().GetBytes(xml);
            using(var memoryStream = new MemoryStream(byteArray))
            {
                var xmlTextReader = new XmlTextReader(memoryStream);
                var retObj = (T) xs.Deserialize(xmlTextReader);
                return retObj;
            }
        }
    }
}